package cn.demo.rdd

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Spark01_ADD_Memory {
  def main(args: Array[String]): Unit = {
    //    create resource
    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("dk")
    val sc = new SparkContext(sparkConf)
    //    create RDD
//    val ints = Seq(1, 2, 3, 4, 5)
//    val rdd = sc.parallelize(ints)
    val rdd:RDD[Int] = sc.makeRDD(List(1, 2, 3, 4, 5),2)

    rdd.saveAsObjectFile("output\\data")
//    val ints1 = rdd.collect()
//    ints1.foreach(println)
    //    close resource
    sc.stop()
  }
}